package mao.algorithm.redbook.demo28_1;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

//断点调试
public class TestTree {
	public static void main(String[] args) throws FileNotFoundException {
		File file = new File("D:test.txt");
		FileReader fis = new FileReader(file);
		BufferedReader in = new BufferedReader(fis);
		
		try {
			int read = Integer.parseInt(in.readLine().trim());
			Graph graph = new Graph(read);
			int u=0;
			int v=0;
			for(int i=0;i<read;i++){
				String line = in.readLine();
				String[] split = line.split(" ");
				for(int j=0;j<split.length;j++){
					if(j == 0){
						 u = Integer.parseInt(split[j]);
					}else{
						v=Integer.parseInt(split[j]);
						graph.addEdge(u, v);
					}
					
				}
				
			}
			Graph.Tree tree = graph.bfs(0);
			int nodeNumber = tree.getNodeNumberOfTree();
			System.out.println(nodeNumber);
			if(nodeNumber == read){
				System.out.println("true");
				
			}else{
				System.out.println("false");
			}
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				in.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}

}
